import Vue from "vue";
import Router from "vue-router";

const routerPush = Router.prototype.push;
Router.prototype.push = function push(location, onComplete, onAbort) {
  return routerPush.call(this, location, onComplete, onAbort).catch((error) => error);
};

Vue.use(Router);
// import Layout from "../views/Layout.vue";
import Error404 from "../views/ErrorPage/404.vue";
import Error401 from "../views/ErrorPage/401.vue";
import Login from "../views/Login";
export const constantRouterMap = [
  {
    path: "/",
    redirect: "/login",
  },
  { path: "/login", component: Login, hidden: true },
  { path: "/401", component: Error401, hidden: true },
  { path: "/404", component: Error404, hidden: true },
  { path: "*", redirect: "/404", hidden: true },
];

export default new Router({
  mode: "history",
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap,
  fallback: false,
});
